/**
 * Created by Administrator on 2025/5/7.
 * */
#ifndef AICFAR_ERA
#define AICFAR_ERA

#include "CudaModule.h"
#include "../GlobalParameters.h"
#include <mutex>
#include <thread>
#include <zmq.hpp>
#include <string>
#include "../include/zy_net.h"

extern "C" BaseObject *createAICFAR();
extern "C" void destroyAICFAR(BaseObject *p);

class AICFAR : public CudaModule {
public:
AICFAR();

~AICFAR();

//void onPushCudaOperations(buffer_table_t *input, buffer_table_t *output, cudaStream_t stream) override;
    void onIssueStreamedCudaOperations(buffer_table_t *input, buffer_table_t *output, cudaStream_t stream) override;
    void zmqRepServe();

private:
    zmq::context_t context;
    // 时间步订阅
    std::string topicAddr = "tcp://192.168.1.115:6001";
    std::string topicName = "MainController";
    zmq::socket_t sub;
    // AIPC通知通道
    zmq::socket_t rep_socket;
    std::string rep_address = "tcp://192.168.1.115:6007";
    float P0 = 0.0; // 初始值
    float P1 = 0.95; // 第一次升级后
    float P2 = 0.985; // 与传统算法不一致调优
    float P3 = 0.991; // 虚拟真值目标调优
    float P4 = 0.996; // 自监督学习调优后
    float precision = P0; // 缺省时为完全错误
    int modelState = 0; // 0---刚上线；1---初次升级；2---传统算法辅助升级；3---虚拟真值目标辅助升级；4---自监督学习升级；
    int prevStep;
};

#endif //TASK2_ERA
